////* libraries if not installed. Remove forward slashes from below////
//ssc install ivreg2
//ssc install outreg2
//ssc install ranktest 

//Import Excel file for your stored location and load the sheet called Mastersheet and ensure the first rows are lables. 

//Set the data as a time series

tsset Year

//Generate the change in energy exports to GDP

gen CEE = d.EEGDP

//This gives the output for Table 1

ivreg2 PB l.PB l.DSI OP (l.OG = CER FI Inf TO), gmm2s robust

ivreg2 PB l.PB l.DSI l.OP (l.OG = CER FI Inf TO), gmm2s robust

ivreg2 PB l.PB l.DSI CEE (l.OG = COG TO FI), gmm2s robust

ivreg2 PB l.PB l.DSI l.CEE (l.OG = CER FI Inf TO), gmm2s robust

//This gives the output for Table 3

ivreg2 PB l.PB l.Debt (l.OG = CER FI Inf TO), gmm2s first robust

ivreg2 PB l.PB l.Debt l.CEE (l.OG = CER FI Inf TO), gmm2s first robust

ivreg2 PB l.PB l.DTR l.CEE (l.OG = CER FI Inf TO), gmm2s first robust

ivreg2 PB l.PB l.DTX l.CEE (l.OG = CER FI Inf TO), gmm2s first robust

ivreg2 PB l.PB l.ITR l.CEE (l.OG = CER FI Inf TO), gmm2s first robust

//This gives the output for Table 8

ivreg2 PB l.PB l.DVI (l.OG = COG TO Inf FI), gmm2s robust

ivreg2 PB l.PB l.DVI l.OP (l.OG = COG TO Inf FI), gmm2s robust 

ivreg2 PB l.PB l.DVI l.CEE (l.OG = COG TO Inf FI), gmm2s robust 

//Import the Stationarity Sheet from the same workbook.

//import excel "C:\Users\User\OneDrive\PhD Thesis\Data and Estimation\Fiscal Reaction Function.xlsx", sheet("Stationarity") firstrow clear 

tsset Year

//This gives the results for Table 5 Part A

varsoc PB

dfuller PB, noconstant lags(1)

dfuller PB, trend regress lags(1)

dfuller PB, drift regress lags(1)

pperron PB, noconstant lags(1)

pperron PB, trend lags(1)

//This gives the results for Table 6 Part A

varsoc TR 

varsoc TE

dfuller TR, noconstant lags(1)

dfuller TR, trend lags(1)

dfuller TR, drift lags(1)

pperron TR, noconstant lags(1)

pperron TR, trend lags(1)

dfuller TE, noconstant lags(1)

dfuller TE, trend lags(1)

dfuller TE, drift lags(1)

pperron TE, noconstant lags(1)

pperron TE, trend lags(1)

//This gives the results for Table 7 Part A

vecrank TR TE, trend(none) lags(1)

vecrank TR TE, trend(constant) lags(1)

vecrank TR TE, trend(trend) lags(1)

//This gives the results for some of the narrative associated with Table 7 Part A

egranger TR TE

vec TR TE, trend(trend) lags(1)

vec TR TE, trend(none) lags(1)

